<template>
	<view class="myactive">
		<view v-for="(item,index) in list" :key="item.huodong_id" class="myactive_cell" @click="goInfo(item)">
			<view class="myactive_img_box">
				<image class="myactive_img" :src="picUrl + item.pic" mode="aspectFill"></image>
			</view>
			<view class="myactive_text_box">
				<view class="c-999999 f-12">{{ item.start_time }}</view>
				<view class="ellipsis-2 f-16 mt-5" style="letter-spacing: 1rpx;">{{ item.huodong_title }}</view>
				<view :class="'myactive_audit ' + (item.huodong_status == 2 ? 'audit_end' : 'audit_ing')">
					{{ item.huodong_status_text }}
				</view>
			</view>
		</view>
		<view class="page_bottom_loading" :style="'padding-bottom:'+pdbottom+'rpx;'">{{loadingTitle}}</view>
		<view v-if="popupImg" class="mask_box" @click="closePopup"></view>
		<view class="popup_img_box" v-if="popupImg">
			<image class="popup_img" :src="onlinePic+'popup_img.png'" mode="widthFix"></image>
			<view class="popup_text_box">
				<text>{{popup_text}}</text>
			</view>
			<view class="popup_sub">
				<view class="sub left" @click="closePopup">关闭弹框</view>
				<view class="sub right" @click="goActiveInfo">查看详情</view>
			</view>
			<!-- <view class="pop_close_icon_box">
				<uni-icons class="pop_close_icon" @click="closePopup" type="close" color="#ffffff"
					size="50"></uni-icons>
			</view> -->
		</view>
	</view>
</template>

<script>
	import {
		getClubMyActiveList
	} from '@/api/motortime.js';
	let app = getApp()
	export default {
		data() {
			return {
				params: {
					page: 1,
					size: 10
				},
				list: [],
				loadingTitle: '',
				popupImg: false,
				popup_text: '',
				huodong_status: '',
				onlinePic: app.globalData.onlinePic,
				picUrl: app.globalData.picUrl
			};
		},
		onShow() {

		},
		onLoad() {
			this.getClubMyActiveList()
			var params = {
				event_code: '我的活动',
				path: 'pages/my/myactive',
				event_id: '',
				title: '',
				source_page: '',
				value: '',
			}
			app.BurialPoint(params)
		},
		methods: {
			getClubMyActiveList() {
				getClubMyActiveList(this.params).then(res => {
					if (res.state == 1) {
						this.list = [...this.list, ...res.data.data]
						this.last_page = res.data.last_page
						this.current_page = res.data.current_page
						if (this.list.length == 0) {
							this.loadingTitle = "- 暂无更多 -"
						}
					} else {
						uni.showToast({
							title: res.error[0],
							mask: true,
							icon: 'none',
							duration: 1500
						})
					}
				})
			},
			goInfo(d) {
				this.huodong_status = d.huodong_status
				this.huodong_id = d.huodong_id
				var params = {
					event_code: '我的活动',
					path: 'pages/my/myactive',
					event_id: d.huodong_id,
					title: '',
					source_page: '我的活动-查看详情',
					value: '',
				}
				app.BurialPoint(params)
				if (d.huodong_status == 1) {
					uni.navigateTo({
						url: '/pages/my/myactiveinfo?huodong_id=' + d.huodong_id
					})
				} else {
					this.popup_text = d.huodong_popup_text
					this.popupImg = true
				}
			},
			closePopup() {
				this.popupImg = false
				this.popup_text = ''
				this.huodong_status = ''
				this.huodong_id = ''
			},
			goActiveInfo() {
				var params = {
					event_code: '我的活动',
					path: 'pages/my/myactive',
					event_id: '',
					title: '',
					source_page: '我的活动-查看详情',
					value: '',
				}
				app.BurialPoint(params)
				uni.navigateTo({
					url: '/pages/group/groupactiveinfo?huodong_id=' + this.huodong_id+'&fromActivelist=1'
				})
				this.popupImg = false
				this.popup_text = ''
				this.huodong_status = ''
				this.huodong_id = ''
			}
		},
		onPullDownRefresh() {
			this.params.page = 1
			this.list = []
			this.getClubMyActiveList()
			uni.stopPullDownRefresh()
		},
		onReachBottom() {
			if (this.current_page < this.last_page) {
				this.showLoading = true
				this.params.page = this.params.page + 1
				this.getClubMyActiveList()
			} else {
				this.showLoading = false
				if (this.list.length > 0) {
					this.loadingTitle = "- 已经到底了 -"
				} else {
					this.loadingTitle = "- 暂无更多 -"
				}

			}
		},
	}
</script>

<style lang="scss">
	.myactive {
		.myactive_cell {
			display: flex;
			align-items: flex-start;
			padding: 30rpx;

			.myactive_img_box {
				width: 210rpx;
				height: 220rpx;

				.myactive_img {
					width: 210rpx;
					height: 220rpx;
					border-radius: 8rpx;
					vertical-align: middle;
				}
			}

			.myactive_text_box {
				flex: 1;
				height: 220rpx;
				position: relative;
				margin-left: 20rpx;

				.myactive_audit {
					position: absolute;
					left: 0;
					bottom: 0;
					color: #00A0DC;
					font-size: 20rpx;
					padding: 2rpx 10rpx;
					border-radius: 8rpx;
					border: 1rpx solid #00A0DC;
				}



				.audit_ing {
					color: #00A0DC;
					border: 1rpx solid #00A0DC;
					background-color: #EBF8FF;
				}

				.audit_end {
					color: #C2C2C2;
					border: 1rpx solid #C2C2C2;
					background-color: #EFEFEF;
				}

			}
		}

		.popup_img_box {
			position: fixed;
			top: 10%;
			left: 60rpx;
			right: 16rpx;
			z-index: 1001;

			.popup_img {
				width: 100%;
				vertical-align: middle;
			}

			.popup_text_box {
				color: #666666;
				font-size: 28rpx;
				position: absolute;
				top: 20%;
				left: 66rpx;
				right: 115rpx;
				z-index: 1002;
				line-height: 42rpx;
			}

			.pop_close_icon_box {
				position: absolute;
				bottom: -80rpx;
				left: 0;
				right: 0;
				z-index: 1002;
				text-align: center;
			}

			.popup_sub {
				margin-top: 20rpx;
				margin-right: 44rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.sub {
					width: 287rpx;
					height: 80rpx;
					line-height: 80rpx;
					color: #FFFFFF;
					font-size: 36rpx;
					background-color: #00A0DC;
					border-radius: 8rpx;
					text-align: center;


					&.left {
						color: #00A0DC;
						background-color: #FFFFFF;
					}
				}
			}

		}
	}
</style>